<?php
/**
 * Created by PhpStorm.
 * User: Kau
 * Date: 2018/3/22
 * Time: 0:45
 */
namespace app\common\model;

use think\Model;

class User extends BaseModel
{
    public function add($data = [])
    {
        if (!is_array($data))
        {
            exception('传递的数据不是数组');
        }

        $data['status'] = 1;
        return $this->data($data)->allowField(true)->save();
    }

    public function getUserByUsername($username)
    {
        if (!$username)
        {
            exception('用户名不合法');
        }
        $data = ['username' => $username];
        return $this->where($data)->find();
    }
}